import pygame
import os
from pygame.locals import *
from defs import *

class WallSection(pygame.sprite.Sprite):

   wall = pygame.image.load(os.path.join('art','wall5.png'))

   def __init__(self, curcenter, curangle):
      pygame.sprite.Sprite.__init__(self)
      texture = pygame.Surface.convert_alpha(self.wall)
      self.image = texture.copy()
      self.image = pygame.transform.rotate(self.image, -curangle)
      self.rect = self.image.get_rect(center=curcenter.center)

   def update(self):
      self.wrap()

   def wrap(self):
      if (self.rect.center[0] < 0):
         self.rect.move_ip(SCREENRECT.width, 0)
      elif (self.rect.center[0] >= SCREENRECT.width):
         self.rect.move_ip(-SCREENRECT.width, 0)            

      if (self.rect.center[1] <  FONT_SIZE):
         self.rect.move_ip(0, SCREENRECT.height - FONT_SIZE)
      elif (self.rect.center[1] >= SCREENRECT.height):
         self.rect.move_ip(0, -SCREENRECT.height + FONT_SIZE)